; (function () {
    return
    /**
   * @param {number[]} height
   * @return {number}
   */
    // 超出时间限制了
    var maxArea = function (height) {
        let max = 0

        for (let i = 0; i < height.length; i++) {
            for (let j = i + 1; j < height.length; j++) {
                let min = Math.min(height[i], height[j])
                max = Math.max(min * (j - i), max)

            }
        }
        return max
    };
    console.log(maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7]));
    console.log(maxArea([1, 1]));
})();

// 每个值都循环了一遍,得到自己可以得到的最大的数值
; (function () {
    //return
    /**
     * @param {number[]} height
     * @return {number}
     */

    var maxArea = function (height) {
        let max = 0
        let left = 0
        let right = height.length - 1

        while (left != right) {
            if (height[left] > height[right]) {

                max = Math.max(max, height[right] * (right - left))
                right--
            } else {

                max = Math.max(max, height[left] * (right - left))
                left++
            }
        }
        return max
    };
    console.log(maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7]));
    console.log(maxArea([1, 1]));

})();